/*    */ package com.zimbra.cs.account.callback;
/*    */ 
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.util.Log;
/*    */ import com.zimbra.common.util.ZimbraLog;
/*    */ import com.zimbra.cs.account.Account;
/*    */ import com.zimbra.cs.account.AttributeCallback;
/*    */ import com.zimbra.cs.account.Entry;
/*    */ import com.zimbra.cs.db.DbOutOfOffice;
/*    */ import com.zimbra.cs.db.DbPool;
/*    */ import com.zimbra.cs.db.DbPool.DbConnection;
/*    */ import com.zimbra.cs.mailbox.Mailbox;
/*    */ import com.zimbra.cs.mailbox.MailboxManager;
/*    */ import java.util.Map;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class OutOfOfficeCallback
/*    */   extends AttributeCallback
/*    */ {
/*    */   public void preModify(CallbackContext context, String attrName, Object value, Map attrsToModify, Entry entry) {}
/*    */   
/*    */   public void postModify(CallbackContext context, String attrName, Entry entry)
/*    */   {
/* 45 */     if (context.isDoneAndSetIfNot(OutOfOfficeCallback.class)) {
/* 46 */       return;
/*    */     }
/*    */     
/* 49 */     if (!context.isCreate()) {
/* 50 */       ZimbraLog.misc.info("need to reset vacation info");
/* 51 */       if ((entry instanceof Account)) {
/* 52 */         handleOutOfOffice((Account)entry);
/*    */       }
/*    */     }
/*    */   }
/*    */   
/*    */   private void handleOutOfOffice(Account account) {
/*    */     try {
/* 59 */       Mailbox mbox = MailboxManager.getInstance().getMailboxByAccount(account);
/*    */       
/* 61 */       DbPool.DbConnection conn = null;
/*    */       try
/*    */       {
/* 64 */         conn = DbPool.getConnection(mbox);
/* 65 */         DbOutOfOffice.clear(conn, mbox);
/* 66 */         conn.commit();
/* 67 */         ZimbraLog.misc.info("reset vacation info");
/*    */         
/*    */ 
/*    */ 
/*    */ 
/* 72 */         long interval = account.getTimeInterval("zimbraPrefOutOfOfficeCacheDuration", 604800000L);
/* 73 */         DbOutOfOffice.prune(conn, interval);
/* 74 */         conn.commit();
/*    */       } catch (ServiceException e) {
/* 76 */         DbPool.quietRollback(conn);
/*    */       } finally {
/* 78 */         DbPool.quietClose(conn);
/*    */       }
/*    */     } catch (ServiceException e) {
/* 81 */       ZimbraLog.misc.warn("error handling out-of-office", e);
/*    */     }
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/account/callback/OutOfOfficeCallback.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */